load("@rules_python//python:defs.bzl", "py_binary")
load("@pip_deps//:requirements.bzl", "requirement")

package(default_visibility = ["//visibility:private"])

licenses(["notice"])

exports_files(["mac_test_keyset.json"])

py_binary(
    name = "mac_cli",
    srcs = ["mac_cli.py"],
    python_version = "PY3",
    deps = [
        requirement("absl-py"),
        "@tink_py//tink:secret_key_access",
        "@tink_py//tink:tink_python",
        "@tink_py//tink/mac",
    ],
)

sh_test(
    name = "mac_test",
    size = "small",
    srcs = ["mac_cli_test.sh"],
    args = [
        "$(rootpath :mac_cli)",
        "$(rootpath :mac_test_keyset.json)",
    ],
    data = [
        ":mac_cli",
        ":mac_test_keyset.json",
    ],
)

# This runs the previous test assuming the Tink python package has been
# installed previously with pip3 install.
sh_test(
    name = "mac_test_package",
    size = "small",
    srcs = ["mac_cli_test.sh"],
    args = [
        "'python3 $(rootpath :mac_cli.py)'",
        "$(rootpath :mac_test_keyset.json)",
    ],
    data = [
        ":mac_cli.py",
        ":mac_test_keyset.json",
    ],
)

py_library(
    name = "mac_basic",
    srcs = ["mac_basic.py"],
    deps = [
        "@tink_py//tink:secret_key_access",
        "@tink_py//tink:tink_python",
        "@tink_py//tink/mac",
    ],
)

py_test(
    name = "mac_basic_test",
    srcs = ["mac_basic_test.py"],
    python_version = "PY3",
    deps = [
        requirement("absl-py"),
        ":mac_basic",
    ],
)
